angular.module('loginApp', [])
    .controller('loginController', function() {

        var login = this;

        login.name="hello";


        //登录
        login.loginsub =  function(){
            var chectReault = this.checkFormData();
            if(chectReault){
                //执行提交操作
                alert("数据校验成功")
            }else{
                //验证失败
                alert("数据校验失败");
                console.log("数据校验失败！")
            }
        };
        //校验表单数据
        login.checkFormData = function () {
            var username = $("input[name='username']").val();
            var password = $("input[name='password']").val();
            var validateCode = $("input[name='validateCode']").val();
            console.log("username:"+username+"----password--"+password+"----validateCode---"+validateCode);
            if(username=='' || password=='' || validateCode==''){
                return false;
            }else{
                return true;
            }
        };

        login.refareshCode=function(){
            $("img").attr("src","/validatecode/image?"+ Math.random());
        };

        login.mouseover=function(){
            $("img").css("cursor","pointer");
        };

    });

